package org.openkoala.koala.wizard.wizardpage.component;

import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.JavaPluginImages;
import org.eclipse.jdt.internal.ui.viewsupport.ImageDescriptorRegistry;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
import org.openkoala.koala.widget.Module;

/**
 * 模块在模块管理界面的显示效果label
 * @author xmfang
 *
 */
@SuppressWarnings("restriction")
public class ModulesLabelProvider extends LabelProvider {
	
	private ImageDescriptorRegistry fRegistry;
	
	public ModulesLabelProvider() {
		fRegistry= JavaPlugin.getImageDescriptorRegistry();
	}
	
	@Override
	public Image getImage(Object element) {
		return fRegistry.get(JavaPluginImages.DESC_OBJS_OUTPUT_FOLDER_ATTRIB);
	}
	
	@Override
	public String getText(Object element) {
		if (element instanceof Module) {
			return ((Module) element).getModuleName();
		}
		return element == null ? "" : element.toString();
	}
}
